package com.qczl.pme.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qczl.pme.dao.CameraDao;
import com.qczl.pme.entity.PMECamera;
import com.qczl.pme.entity.PMESewise;
import com.qczl.pme.service.RecordingService;
import com.qczl.util.HttpClientUtil;

/**
 * 视频录制业务逻辑层实现类
 * 
 * @作者:SongR
 * @日期:2017年9月21日下午3:05:23
 */
@Service
public class RecordingServiceImpl implements RecordingService {

	@Autowired
	CameraDao cameradao;

	/**
	 * 实现停止录制
	 */
	@Override
	public String stopV1(String cameraid, String taskid) throws Exception {
		PMECamera camera = cameradao.get(PMECamera.class, new Long(cameraid));
		if (camera != null) {
			PMESewise sewise = camera.getSewise();
			String port = "";
			if (sewise.getProt2() != null && !sewise.getProt2().equals("")) {
				port += ":" + sewise.getProt2();
			}
			String url = "http://" + sewise.getIp() + port + "/record";
			Map<String, String> map = new HashMap<String, String>();
			map.put("do", "stop");
			map.put("taskid", taskid);
			String s = HttpClientUtil.doPost(url, map);
			return s;
		}
		return "";
	}

}
